﻿using Microsoft.Extensions.Configuration;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;

namespace FilterIllegalCharacter.UI
{
    public class AppSettings
    {
        public AppSettings() 
        {
            RemoteDictUrl = new List<string>();
            RemoteAccountUrl = string.Empty;
        }
        /// <summary>
        /// 远程词库地址
        /// </summary>
        public List<string> RemoteDictUrl { get; set; }
        /// <summary>
        /// 远程账号密码
        /// </summary>
        public string RemoteAccountUrl { get; set; }
    }
    public class ConfigurationHelper
    {
        public static AppSettings? AppSettings => GetConfigurationRoot().GetSection("AppSettings").Get<AppSettings>();
        public static IConfigurationRoot GetConfigurationRoot()
        {
            // 建立配置构建器
            var builder = new ConfigurationBuilder()
                .SetBasePath(Directory.GetCurrentDirectory())
                .AddJsonFile("appsettings.json", optional: false, reloadOnChange: true);
            // 创建配置根对象
            return builder.Build();
        }
    }
}
